package testClasses.misc;

import gameAppLayer.enums.Constants;

import java.util.Random;

import stars.StarModelBuilder;
import stars.StarModel;
import stars.enums.EStarType;

public class TestFMStar {
	
	Random rand = new Random();
	
	public void runTest() {
		
		StarModelBuilder starFact = new StarModelBuilder();
		
		EStarType type = EStarType.T_TAURI;		
		StarModel tempStar;
		
		double age = 0.0;
		double lifetime = 0.0;
		double mass = 0.0;
		double temp = 0.0;
		double gravity = 0.0;
		double luminosity = 0.0;
		double rotation = 0.0;
		double magField = 0.0;
		double radius = 0.0;
		
		double numStars = 10000;
		for (int i = 0; i < numStars; i++) {
			double temperature = randomTemperature(type);			
			tempStar = starFact.createMStar(temperature, type);
			
//			System.out.println("Star Type: " + tempStar.getType().toString());
//			System.out.println("Star Age: " + tempStar.getAge());
//			System.out.println("Star Lifetime: " + tempStar.getLifetime());
//			System.out.println("Star Mass: " + tempStar.getMass());
//			System.out.println("Star Temp: " + tempStar.getTemperature());
//			System.out.println("Star Color: " + tempStar.getColor().toString());
//			System.out.println("Star Gravity: " + tempStar.getGravity());
//			System.out.println("Star Luminosity: " + tempStar.getLuminosity());
//			System.out.println("Star Rotation: " + tempStar.getRotation());
//			System.out.println("Star MagField: " +tempStar.getMagField());			
//			System.out.println("Star Radius: " + tempStar.getRadius());
//			System.out.println("Star Orbit: " + tempStar.getOrbitRadius());
//			System.out.println("Star Stability: " + tempStar.getStability().get(0).toString());
//			//System.out.println("Star X Location: " + tempStar.getLocation().x);
//			System.out.println("");
			
			age += tempStar.getAge();
			lifetime += tempStar.getLifetime();
			mass += tempStar.getMass();
			temp += tempStar.getTemperature();
			gravity += tempStar.getGravity();
			luminosity += tempStar.getLuminosity();
			rotation += tempStar.getRotation();
			magField += tempStar.getMagField();
			radius += tempStar.getRadius();
		}
		
		System.out.println("Age: " + age/numStars);
		System.out.println("Life: " + lifetime/numStars);
		System.out.println("Mass: " + mass/numStars);
		System.out.println("Temp: " + temp/numStars);
		System.out.println("Grav: " + gravity/numStars);
		System.out.println("Lumi: " + luminosity/numStars);
		System.out.println("Rota: " + rotation/numStars);
		System.out.println("MagF: " + magField/numStars);
		System.out.println("Radi: " + radius/numStars);
	}
	
	
	private double randomTemperature(EStarType type) {
		double maxTemp = type.getMaxTemp();
		double minTemp = type.getMinTemp();
		double tempRange = maxTemp - minTemp;
		double temperature = rand.nextDouble()*tempRange + minTemp;
		
		return temperature;
		
	}
	
	public static void main(String[] args) {
		TestFMStar test = new TestFMStar();
		test.runTest();
	}

}
